package com.powernode.myspring.bean.spring6.bean;

import org.springframework.beans.factory.FactoryBean;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DataFactoryBean implements FactoryBean {
    // DataFactoryBean这个工厂Bean协助我们Spring创建这个普通的Bean；Data
    private String strdata;

    public DataFactoryBean(String strdata) {
        this.strdata = strdata;
    }

    @Override
    public Object getObject() throws Exception {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date = simpleDateFormat.parse(strdata);
        return date;
    }

    @Override
    public Class<?> getObjectType() {
        return null;
    }
}
